home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / c / hce.lha / HCE / LibSource / clib / Misc / src / setjmp.a < prev    next >
Encoding:
Text File  |  1992-09-02  |  952 b   |  44 lines

  1. ;
  2. ; setjmp - saves the context of a process(?) in a buffer so a call
  3. ;       to longjmp can restore it.
  4. ;
  5. ; From the Hcc.lib by Detlef Wurkner, Placed here by Jason Petty.
  6. ;
  7.  
  8.     XDEF _setjmp
  9.     XDEF _longjmp
  10.  
  11. ; CODE setjmp_code  (this had to be removed as Aztec doesn't like)
  12.     EVEN
  13. _setjmp:
  14.     move.l    4(sp),a0        ; get pointer to save array
  15.     move.l    (sp),a1        ; get return address
  16.     move.l    a1,(a0) ; save return address
  17.     movem.l d2-d7/a2-a7,4(a0)
  18.  
  19.     clr.l    d0
  20.     rts
  21.  
  22. ;
  23. ; longjmp - restores the context saved by a call to setjmp, which causes
  24. ;        the process to do a jump to where the setjmp was called
  25. ;        i.e. looks like the setjmp returned again.
  26. ;
  27. ;
  28. _longjmp:
  29.     move.l    4(sp),a0        ;get pointer to save_env
  30.     move.l    8(sp),d0        ;get return value
  31.     tst.l    d0
  32.     bne    not_zero    ; if the return value is zero set it to 1
  33.     move.l    #1,d0
  34. not_zero:
  35.     movem.l 4(a0),d2-d7/a2-a7
  36.     move.l    (a0),(sp)       ; write return address
  37.  
  38.     rts ;here goes nothing.
  39.  
  40.     END
  41.  
  42.  
  43.  
  44.